package org.wlc.demov3.service.impl;

import org.wlc.Result;
import org.wlc.demov1.EStatus;
import org.wlc.demov3.service.State;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author 王立朝
 * @date 2022/5/11
 * @description:
 */
public class StateHandler {
    private Map<Enum<EStatus>, State> stateMap = new ConcurrentHashMap<Enum<EStatus>, State>();

    public StateHandler() {
        // 待审核
        stateMap.put(EStatus.Check, new CheckState());
        // 已关闭
        stateMap.put(EStatus.Close, new CloseState());
        // 活动中
        stateMap.put(EStatus.Doing, new DoingState());
        // 编辑中
        stateMap.put(EStatus.Editing, new EditingState());
        // 已开启
        stateMap.put(EStatus.Open, new OpenState());
        // 审核通过
        stateMap.put(EStatus.Pass, new PassState());
        // 审核拒绝
        stateMap.put(EStatus.Refuse, new RefuseState());
    }

    /**
     * 活动提审
     * @param activityId
     * @param currentStatus
     * @return
     */
    public Result arraignment(String activityId, Enum<EStatus> currentStatus) {
        return stateMap.get(currentStatus).arraignment(activityId, currentStatus);
    }

    /**
     * 审核通过
     * @param activityId
     * @param currentStatus
     * @return
     */
    public Result checkPass(String activityId, Enum<EStatus> currentStatus) {
        return stateMap.get(currentStatus).checkPass(activityId, currentStatus);
    }

    /**
     * 审核拒绝
     * @param activityId
     * @param currentStatus
     * @return
     */
    public Result checkRefuse(String activityId, Enum<EStatus> currentStatus) {
        return stateMap.get(currentStatus).checkRefuse(activityId, currentStatus);
    }

    /**
     * 审核撤销
     * @param activityId
     * @param currentStatus
     * @return
     */
    public Result checkRevoke(String activityId, Enum<EStatus> currentStatus) {
        return stateMap.get(currentStatus).checkRevoke(activityId, currentStatus);
    }

    /**
     * 活动关闭
     * @param activityId
     * @param currentStatus
     * @return
     */
    public Result close(String activityId, Enum<EStatus> currentStatus) {
        return stateMap.get(currentStatus).close(activityId, currentStatus);
    }

    /**
     * 活动开启
     * @param activityId
     * @param currentStatus
     * @return
     */
    public Result open(String activityId, Enum<EStatus> currentStatus) {
        return stateMap.get(currentStatus).open(activityId, currentStatus);
    }

    /**
     * 活动中
     * @param activityId
     * @param currentStatus
     * @return
     */
    public Result doing(String activityId, Enum<EStatus> currentStatus) {
        return stateMap.get(currentStatus).doing(activityId, currentStatus);
    }

}
